package com.review.Demo_17_线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;


public class UseExecutors {

	public static void main(String[] args) {
		
		//single
		ExecutorService pool1 = Executors.newSingleThreadExecutor();
		//fixied
		ExecutorService pool2 = Executors.newFixedThreadPool(10);
		//cache
		ExecutorService pool3 = Executors.newCachedThreadPool();
		//schedule
		ScheduledExecutorService pool4 = Executors.newScheduledThreadPool(10);
		
		
		//自定义线程池---若上四种不满足，可自定义
		ExecutorService threadPoolExecutor = new ThreadPoolExecutor(1, 1,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());
		
	}
}
